package com.yanqu.road.server.cmd.activity.flowerstudy;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.FlowerStudyProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.activity.flowerstudy.CrossFlowerStudyMgr;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = CrossProtocol.C_FLOWER_STUDY_EXAM_CHOOSE_ANSWER, desc = "花城书房跨服选择答案")
public class CrossFlowerStudyChooseAnswerCmd extends CrossCommand {


    private int activityId;

    private int questionIndex;

    private int choose;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        FlowerStudyProto.FlowerStudyExamChooseReq req = FlowerStudyProto.FlowerStudyExamChooseReq.parseFrom(packet.getBytes());
        activityId = req.getActivityId();
        questionIndex = req.getQuestionIndex();
        choose = req.getChoose();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        FlowerStudyProto.FlowerStudyExamChooseResp.Builder builder = CrossFlowerStudyMgr.chooseAnswer(activityId, packet.getPlayerId(), questionIndex, choose);
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(ClientProtocol.U_FLOWER_STUDY_EXAM_CHOOSE_ANSWER,builder);
        MessageHelper.sendPacket(serverId,packet.getPlayerId(),pbMsg);
    }

    @Override
    public void sendData() {

    }
}
